//
//  OutMailViewController.m
//  Utils
//
//  Created by enghou on 2018/6/11.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "OutMailViewController.h"
#import "SearchOutMailViewController.h"
#import "OutMailDetailViewController.h"
#import "OutMailItemModel.h"
@interface OutMailViewController ()

@end

@implementation OutMailViewController
-(instancetype)init{
    self = [super init];
    if (self) {
        self.cellClass = @"OutMailCell";
        self.modelClsName = @"OutMailItemModel";
        self.path = @"/mobile/comprehensiveGovernance/outbox/searchOutboxMessage.action";
    }
    return self;
}

-(void)searchAction{
    SearchOutMailViewController *searchOut = [[SearchOutMailViewController alloc]init];
    searchOut.title = @"发件消息查询";
    searchOut.theDelete = self;
    [self push:searchOut];
}

//-(void)addTextReport{
//    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
//    outDetail.title = @"发件详情";
//    outDetail.type = 0;
//    [self push:outDetail];
//}
//
//-(void)addMovReport{
//    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
//    outDetail.title = @"发件详情";
//    outDetail.type = 2;
//    [self push:outDetail];
//}
//
//-(void)addSoundReport{
//    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
//    outDetail.title = @"发件详情";
//    outDetail.type = 1;
//    [self push:outDetail];
//}

//-(void)addPhotoReport{
//    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
//    outDetail.title = @"发件详情";
//    outDetail.type = 3;
//    [self push:outDetail];
//}

-(void)addAction{
    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
    outDetail.title = @"发件详情";
    [self push:outDetail];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *barButton = self.navigationItem.rightBarButtonItems[0];
//    self.navigationItem.rightBarButtonItem = barButton;
    self.navigationItem.rightBarButtonItems = nil;
    self.navigationItem.rightBarButtonItems = @[barButton];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(beginRefresh) name:@"refresh_out_mail" object:nil];
}

-(NSDictionary *)param{
    NSMutableDictionary *param = [[super param]mutableCopy];
    if ([self.choosenParam isKindOfClass:[NSDictionary class]]) {
        [param addEntriesFromDictionary:self.choosenParam];
    }
    return param;
}

-(void)fetchModel:(id)model{
    if ([model isKindOfClass:[NSDictionary class]]) {
        self.choosenParam = model;
        [self beginRefresh];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    OutMailItemModel *model = self.source[indexPath.row];
    OutMailDetailViewController *outDetail = [[OutMailDetailViewController alloc]init];
    outDetail.title = @"发件详情";
    outDetail.ids = model.ID;
    [self push:outDetail];
}

@end
